package com.bstek.pms.tools.dao.db;

import com.bstek.pms.tools.model.TableInfo;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

/**
 * @Description TODO
 * @Author hans
 * @CreateDate 2020-6-27
 */
public class TableInfoDao  extends JdbcDaoSupport {

    /**
     * 查询所有的表结构
     * @return
     */
    public List<TableInfo> getTables(){
        String sql="select rownum n, a.TABLE_NAME,b.comments from user_tables a ,user_tab_comments b where a.TABLE_NAME=b.table_name";
        return this.getJdbcTemplate().query(sql,new RowMapper<TableInfo>(){
            @Override
            public TableInfo mapRow(ResultSet rs, int i) throws SQLException {
                TableInfo t =new TableInfo(rs.getInt(0)+"",rs.getString(1),rs.getString(2));
                return t;
            }
        });
    }
}
